package com.example.allshengmedical.util;

import java.math.BigDecimal;
import java.math.MathContext;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class ScientificNotationUtil {
	
	  public static String parseFormate(double data){
	        int val = (int)Math.abs(data);
	        String form;
	        if (val/100 <=0 && val >0){// 1-100之间
	            form = "0.0000";
	        }else{
	            // 0.1-0.01之间
	            int val2 = (int)(Math.abs(data)*10);
	            if (val2 > 0 && Math.abs(data) <1){
	                form = "0.0000";
	            }else{
	                form = "0.0000e0";
	            }
	            if (data == 0){
	                form = "0.0000";
	            }
	        }
	        BigDecimal bigDecimal = new BigDecimal(data,new MathContext(5));
	        NumberFormat formatter = new DecimalFormat(form);
	        return formatter.format(Double.valueOf(bigDecimal.toPlainString()));
	    }
}
